#ifndef __ALSA_RECORDER_H
#define __ALSA_RECORDER_H

#pragma once

#include "AlsaCore.h"
#include "RingBuffer.h"

class AlsaPcmRecorder;


typedef struct _threadData_DoAudioCapture {
    RingBuffer*         pRingBuffer;
    AlsaPcmRecorder*    pAlsa;
    unsigned long       nChunkReadSize;
    ALSA_AUDIO_PARAMS   audioParams;
    bool                bSaveToFile;
} ThreadData_DoAudioCapture;


class AlsaPcmRecorder : public AlsaCore
{
public:
    AlsaPcmRecorder();
    virtual ~AlsaPcmRecorder();

    static void* DoAudioCapture(void *data);
                                        // renamed from doAudioStream() because streaming can be meaning
                                        // playing instead of capturing

    int StartAudioCapture();			// Start the audio streaming
    int EndAudioCapture();              // End the audio streaming

    int get_capture_stop() { return capture_stop; };

    int GetPrevRecording( int nSec, unsigned char* pBuf);	// Get the last n sec of recording

protected:
    RingBuffer         *m_pRingBuffer;     // Ring buffer handle
    pthread_t           m_threadAudioCapture; // Read sound buffer rthread
    int                 m_ringBufferSize;     // Ring buffer size
    ThreadData_DoAudioCapture m_threaddataAudioCapture;


};

#endif
